Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

286
Visualizações
Testing a custom validation using Vee-Validate fails with "UnhandledPromiseRejection" error

I am trying to test signup functionality and am getting this error:

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "Error: [vee-validate] No such validator 'verify_password' exists.".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

This is the test:

it('routes to root when successfully signed up', async () => {
    let router = new VueRouter()
    const wrapper = mount(SignUpUser, {
      localVue,
      router,
    })

    const usernameField = wrapper.findComponent('#username');
    usernameField.setValue('Avi')

    const emailField = wrapper.findComponent("#email")
    emailField.setValue('avi@avi.com')

    const passwordField = wrapper.findComponent('#password')
    passwordField.setValue('Admin@123')

    const passwordConfirmationField = wrapper.findComponent('#password_confirmation')
    passwordConfirmationField.setValue('Admin@123')

    const submitBtn = wrapper.findComponent('button')

    submitBtn.trigger('click');

    expect(router.currentRoute.path).toBe('/')
  })

This is the particular HTML element where I am using the verify_password validation:

            <input
              id="password"
              ref="password"
              v-model="password"
              v-validate="'required|min:8|verify_password'"
              type="password"
              name="password"
            >

The verify_password validation is defined in app.vue as such:

Vue.use(VeeValidate);
<script>
import BackToTop from 'vue-backtotop'
import eventService from './eventService'
import VeeValidate from 'vee-validate'

VeeValidate.Validator.extend('verify_password', {
  getMessage: (field) => `The password must contain at least: 1 uppercase letter, 
                          1 lowercase letter, 1 number, and one special character (E.g. , . _ & ? etc)`,
  validate: (value) => {
    let strongRegex = new RegExp('^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})')
    return strongRegex.test(value)
  },
})

The validation works perfectly in the browser but the test fails.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda